home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-04 | 3.2 KB | 114 lines | [TEXT/CWIE] |
- unit MyEvents;
-
- interface
-
- uses
- Events;
-
- function EventHasOptionKey( const er: EventRecord ): Boolean;
- function EventHasCommandKey( const er: EventRecord ): Boolean;
- function EventHasControlKey( const er: EventRecord ): Boolean;
- function EventHasShiftKey( const er: EventRecord ): Boolean;
- function EventChar( const er: EventRecord ): char;
- function EventCharCode( const er: EventRecord ): integer;
- function EventKeyCode( const er: EventRecord ): integer;
- function EventIsSuspendResume( const er: EventRecord ): Boolean;
- function EventHasResume( const er: EventRecord ): Boolean;
- function EventIsMouseMoved( const er: EventRecord ): Boolean;
- function EventHasActivate( const er: EventRecord ): Boolean;
- function EventIsKeyDown( const er: EventRecord ): Boolean;
- function EventHasOK( const er: EventRecord ): Boolean;
- function EventHasCancel( const er: EventRecord ): Boolean;
- function EventHasDiscard( const er: EventRecord ): Boolean;
-
- implementation
-
- uses
- Types, MyTypes;
-
- function EventHasOptionKey( const er: EventRecord ): Boolean;
- begin
- EventHasOptionKey := band(SInt32(Ord4(er.modifiers)), optionKey) <> 0;
- end;
-
- function EventHasCommandKey( const er: EventRecord ): Boolean;
- begin
- EventHasCommandKey := band(SInt32(Ord4(er.modifiers)), cmdKey) <> 0;
- end;
-
- function EventHasControlKey( const er: EventRecord ): Boolean;
- begin
- EventHasControlKey := band(SInt32(Ord4(er.modifiers)), controlKey) <> 0;
- end;
-
- function EventHasShiftKey( const er: EventRecord ): Boolean;
- begin
- EventHasShiftKey := band(SInt32(Ord4(er.modifiers)), shiftKey) <> 0;
- end;
-
- function EventChar( const er: EventRecord ): char;
- begin
- EventChar := Chr(band(SInt32(Ord4(er.message)), charCodeMask));
- end;
-
- function EventCharCode( const er: EventRecord ): integer;
- begin
- EventCharCode := band(SInt32(Ord4(er.message)), charCodeMask);
- end;
-
- function EventKeyCode( const er: EventRecord ): integer;
- begin
- EventKeyCode := bsr(band(SInt32(Ord4(er.message)), keyCodeMask),8);
- end;
-
- function EventIsSuspendResume( const er: EventRecord ): Boolean;
- begin
- EventIsSuspendResume := band(brotl(SInt32(Ord4(er.message)), 8), $00FF) = kSuspendResumeMessage;
- end;
-
- function EventHasResume( const er: EventRecord ): Boolean;
- begin
- EventHasResume := band(SInt32(Ord4(er.message)), kResumeMask) <> 0;
- end;
-
- function EventIsMouseMoved( const er: EventRecord ): Boolean;
- begin
- EventIsMouseMoved := band(brotl(SInt32(Ord4(er.message)), 8), $00FF) = kMouseMovedMessage;
- end;
-
- function EventHasActivate( const er: EventRecord ): Boolean;
- begin
- EventHasActivate := odd(er.modifiers);
- end;
-
- function EventIsKeyDown( const er: EventRecord ): Boolean;
- begin
- EventIsKeyDown := (er.what = keyDown) or (er.what = autoKey);
- end;
-
- function EventHasOK( const er: EventRecord ): Boolean;
- var
- ch: char;
- begin
- ch := EventChar( er );
- EventHasOK := (ch = cr) or (ch = enter);
- end;
-
- function EventHasCancel( const er: EventRecord ): Boolean;
- var
- ch: char;
- begin
- ch := EventChar( er );
- EventHasCancel := ((ch = '.') and EventHasCommandKey( er )) or (ch = esc);
- end;
-
- function EventHasDiscard( const er: EventRecord ): Boolean;
- var
- ch: char;
- begin
- ch := EventChar( er );
- EventHasDiscard := (ch = 'd') and EventHasCommandKey( er );
- end;
-
- end.
-